home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1994 November / Cd Ware (Nro. 2) - Epimundo.iso / DOS / PG / CL_STYLE.ZIP / DOSLIB06.CLA < prev    next >
Encoding:
Text File  |  1994-02-11  |  36.3 KB  |  791 lines

  1.                  Member('DOSLIB')
  2.                  Eject('Program Identification Section')
  3. !
  4. !  ┌──────────────────────┐
  5. !  │Program Identification├──────────────────────────────────────────────────────
  6. !  └──────────────────────┘
  7. !
  8. !  Program Name           : Doslib06.Cla
  9. !  Program Description    : Allows Modification of Printer Control Codes
  10. !  Version                : 1.00a
  11. !  Date                   : 02 Janurary 1994
  12. !  Programmer             : Trevor G. Leybourne
  13. !
  14. !  ┌──────────────────────┐
  15. !  │Invocation Structure  ├─────────────────────────────────────────────────────
  16. !  └──────────────────────┘
  17. !
  18. !  Functions Called       : ListPrinters - Lists all Available Printers
  19. !                         : EditPrinters - Allows Editing of Printers
  20. !                         : ListControls - Lists all Available Controls
  21. !                         : EditControls - Allows Editing of Sequences
  22. !                         : ImportPrinters - Imports from Another File
  23. !
  24. !  ┌──────────────────────┐
  25. !  │Input/Output          ├─────────────────────────────────────────────────────
  26. !  └──────────────────────┘
  27. !
  28. !  Datafiles Read         : <Printers.CTL> - Printers File - ASCII Driver
  29. !  Datafiles Updated      : <Printers.CTL> - Printers File - ASCII Driver
  30. !
  31. !  ┌──────────────────────┐
  32. ! ┌┤Functional Description├────────────────────────────────────────────────────┐
  33. ! │└──────────────────────┘                                                    │
  34. ! │                                                                            │
  35. ! │ This program is based on the Clarion CDD Environment Printers Editor.      │
  36. ! │ It allows the user to Load a Printer Control File, Change it and Write it  │
  37. ! │ back.                                                                      │
  38. ! └────────────────────────────────────────────────────────────────────────────┘
  39. !
  40. !  ┌──────────────────────┐
  41. ! ┌┤Modification History  ├────────────────────────────────────────────────────┐
  42. ! │└──────────────────────┘                                                    │
  43. ! │ Ver. Date           Programmer               Summary of Changes            │
  44. ! ├────────────────────────────────────────────────────────────────────────────┤
  45. ! │                                                                            │
  46. ! │ 1.01 02-Jan-1994    Trevor G. Leybourne      Original Production Version   │
  47. ! │                                                                            │
  48. ! └────────────────────────────────────────────────────────────────────────────┘
  49. !
  50.                  Map
  51.                    ListPrinters
  52.                    EditPrinters
  53.                    ListControls
  54.                    EditControls
  55.                    LoadControls(Queue,Queue,Queue,Queue)
  56.                    SaveControls
  57.                    ImportPrinters
  58.                  .
  59.  
  60. OMIT('╝')
  61. ╔════════════════════════════════════════════════════════════════════════════╗
  62. ║ Global Data Declarations                                                   ║
  63. ╚════════════════════════════════════════════════════════════════════════════╝
  64.  
  65. PrinterFilename    String(64)          ! Filename for PRINTER.CTL
  66. HighestPrinter     Short               ! Highest Printer Number
  67. HighestControl     Short               ! Highest Control Number
  68. ChangedFlag        Byte(0)             ! Anything been Changed Flag
  69. ActionMode1        Byte(0)             ! Mode for Current Action (Printers)
  70. ActionMode2        Byte(0)             ! Mode for Current Action (Controls)
  71. Action:Insert      Equate(1)           !   Inserting
  72. Action:Change      Equate(2)           !   Changing
  73. Action:Delete      Equate(3)           !   Deleting
  74.  
  75. Printers           Queue               ! Queue of Printer Names
  76. Printers:Number      Short             !   Printer Number
  77. Printers:Name        String(80)        !   Name of the Printer
  78.                    .                   !
  79. Ports              Queue               ! Queue of Port Names
  80. Ports:Number         Short             !   Printer Number (Related)
  81. Ports:Name           String(4)         !   Port Name
  82.                    .                   !
  83. Controls           Queue               ! Queue of Control Name
  84. Controls:Number      Short             !   Control Number
  85. Controls:Name        String(80)        !   Control Name
  86.                    .                   !
  87. Sequences          Queue               ! Queue of Control Sequences
  88. Seq:Key              Group             !   Key into this Record
  89. Seq:Printer            Short           !     Printer Number
  90. Seq:Number             Short           !     Control Number
  91.                      .                 !   End of Key
  92. Seq:Sequence         String(80)        !   Control Sequence
  93.                    .                   !
  94. ControlSequence    Queue               ! Queue to Display in Main Table
  95. Ctl:Number           Short             !   Control Sequence Number
  96. Ctl:DisplayGroup     Group
  97. Ctl:Name               String(30)      !   Display Control Name
  98. Ctl:BlankSpace         String(' ')     !   Blank Space
  99. Ctl:Sequence           String(13)      !   Display Control Sequence
  100.                    . .
  101. PrintersFile       File,Create,Driver('ASCII'),Name(PrinterFileName)
  102. Record             Record
  103. PrinterRecord        String(80)
  104.                    . .
  105.  
  106.  
  107. OMIT('╝')
  108. ╔════════════════════════════════════════════════════════════════════════════╗
  109. ║ ViewPrinters - Entry Point for the Procedure(s)                            ║
  110. ╚════════════════════════════════════════════════════════════════════════════╝
  111. ViewPrinters       Procedure(DefaultFileName)
  112.  
  113.                    Code
  114.                    If Omitted(1) then
  115.                       PrinterFileName = GetFileDetails('PRINTER.CTL','Printer Control File','*.CTL')
  116.                    Else
  117.                       PrinterFileName = DefaultFileName
  118.                    .
  119.                    If Clip(PrinterFileName) = '' Then Return.
  120.  
  121.                    LoadControls(Printers,Ports,Controls,Sequences)
  122.  
  123.                    Get(Printers,Records(Printers))
  124.                    HighestPrinter = Printers:Number
  125.                    Get(Controls,Records(Controls))
  126.                    HighestControl = Controls:Number
  127.  
  128.                    ChangedFlag = 0
  129.                    ListPrinters
  130.                    If ChangedFlag then SaveControls.
  131.                    Return
  132.  
  133. OMIT('╝')
  134. ╔════════════════════════════════════════════════════════════════════════════╗
  135. ║ ListPrinters - Lists the Printers on the Screen                            ║
  136. ╚════════════════════════════════════════════════════════════════════════════╝
  137. ListPrinters       Procedure
  138.  
  139. Printers_List    SCREEN(23,59),SHADOW,CUA,COLOR(1)
  140.                    !dimensions=25,80,25,80
  141.                    !style=D:\CLARION\DEVELOP\DOSLIB\CLARION.STY
  142.                    ROW(21,2)   PAINT(1,1),COLOR(23)
  143.                    ROW(22,2)   PAINT(1,1),COLOR(119)
  144.                    ROW(1,1)    STRING('█{25}'),COLOR(3)
  145.                      COL(26)   STRING('Printers'),COLOR(2)
  146.                      COL(34)   STRING('█{26}'),COLOR(3)
  147.                    ROW(23,1)   STRING('█▄{57}█'),COLOR(3)
  148.                                REPEAT(21)
  149.                    ROW(2,1)      STRING('█'),COLOR(3)
  150.                    ROW(2,59)     STRING('█'),COLOR(3)
  151.                                .
  152. File_Name          ROW(3,4)    STRING(@s53),COLOR(8)
  153.                    ROW(5,4)    LIST(15,53),FROM(Printers:Name),HVSCROLL,USE(?Printers:Name),HIDE,COLOR(21,22,120)
  154.                    ROW(21,5)   BUTTON(' I&mport '),SHADOW,USE(?Printers:Import),COLOR(17,18,39,19,20)
  155.                      COL(16)   BUTTON(' &Insert '),SHADOW,KEY(InsKey),USE(?Printers:Insert),COLOR(17,18,39,19,20)
  156.                      COL(27)   BUTTON(' &Change '),SHADOW,KEY(EnterKey),USE(?Printers:Change),COLOR(17,18,39,19,20)
  157.                      COL(38)   BUTTON(' &Delete '),SHADOW,KEY(DelKey),USE(?Printers:Delete),COLOR(17,18,39,19,20)
  158.                      COL(49)   BUTTON(' &Exit '),SHADOW,KEY(EscKey),USE(?Printers:Exit),COLOR(17,18,39,19,20)
  159.                  .
  160.                  Code
  161.                  Open(Printers_List)
  162.                  File_Name = Center(Clip(PrinterFileName),Size(File_Name))
  163.                  Loop
  164.                    Accept
  165.                    Get(Printers,Choice())
  166.  
  167.                    Case Field()
  168.                    Of ?Printers:Name
  169.                    Of ?Printers:Import
  170.                       ImportPrinters
  171.                       Select(?Printers:Name,1)
  172.                    Of ?Printers:Insert
  173.                       ActionMode1 = Action:Insert
  174.                       Clear(Printers)
  175.                       Clear(Ports)
  176.                       EditPrinters
  177.                       Select(?Printers:Name)
  178.                    Of ?Printers:Change
  179.                       ActionMode1 = Action:Change
  180.                       EditPrinters
  181.                       Select(?Printers:Name)
  182.                    Of ?Printers:Delete
  183.                       ActionMode1 = Action:Delete
  184.                       EditPrinters
  185.                       Select(?Printers:Name)
  186.                    Of ?Printers:Exit
  187.                       Break
  188.                  . .
  189.                  Close(Printers_List)
  190.                  Return
  191.  
  192. OMIT('╝')
  193. ╔════════════════════════════════════════════════════════════════════════════╗
  194. ║ EditPrinters - Allows Editing of the Printer Name/Port                     ║
  195. ╚════════════════════════════════════════════════════════════════════════════╝
  196. EditPrinters       Procedure
  197.  
  198. Printers_Edit    SCREEN(12,51),SHADOW,CUA,COLOR(1)
  199.                    !dimensions=25,80,25,80
  200.                    !style=D:\CLARION\DEVELOP\DOSLIB\CLARION.STY
  201.                    ROW(4,10)   PAINT(1,5),COLOR(10)
  202.                    ROW(4,24)   PAINT(1,5),COLOR(10)
  203.                    ROW(5,19)   PAINT(4,1),COLOR(10)
  204.                    ROW(1,1)    STRING('█{13}'),COLOR(3)
  205.                      COL(14)   STRING('Add/Update Printer Model'),COLOR(31)
  206.                      COL(38)   STRING('█{14}'),COLOR(3)
  207.                    ROW(12,1)   STRING('█▄{49}█'),COLOR(3)
  208.                                REPEAT(10)
  209.                    ROW(2,1)      STRING('█'),COLOR(3)
  210.                    ROW(2,51)     STRING('█'),COLOR(3)
  211.                                .
  212.                    ROW(3,4)    PROMPT('Name :'),COLOR(4,5,40,6,7)
  213.                      COL(10)   ENTRY(@s40),USE(Printers:Name),COLOR(8,9,38)
  214.                    ROW(4,4)    PROMPT('Port :'),COLOR(4,5,40,6,7)
  215.                                OPTION,USE(Ports:Name)
  216.                      COL(15)     RADIO('NONE '),COLOR(15,16,37,41,42)
  217.                    ROW(5,10)     RADIO('LPT1 '),COLOR(15,16,37,41,42)
  218.                    ROW(6,10)     RADIO('LPT2 '),COLOR(15,16,37,41,42)
  219.                    ROW(7,10)     RADIO('LPT3 '),COLOR(15,16,37,41,42)
  220.                    ROW(8,10)     RADIO('LPT4 '),COLOR(15,16,37,41,42)
  221.                    ROW(5,20)     RADIO('COM1 '),COLOR(15,16,37,41,42)
  222.                    ROW(6,20)     RADIO('COM2 '),COLOR(15,16,37,41,42)
  223.                    ROW(7,20)     RADIO('COM3 '),COLOR(15,16,37,41,42)
  224.                    ROW(8,20)     RADIO('COM4 '),COLOR(15,16,37,41,42)
  225.                                .
  226.                    ROW(10,8)   BUTTON(' Con&trols '),SHADOW,KEY(AltT),USE(?Ports:Controls),COLOR(17,18,39,19,20)
  227.                      COL(23)   BUTTON('  &Ok  '),SHADOW,KEY(EnterKey),USE(?Ports:Ok),COLOR(17,18,39,19,20)
  228.                      COL(34)   BUTTON(' &Cancel '),SHADOW,KEY(EscKey),USE(?Ports:Cancel),COLOR(17,18,39,19,20)
  229.                  .
  230.                  Code
  231.                  Open(Printers_Edit)
  232.                  If ActionMode1 = Action:Delete then Disable(?Printers:Name,?Ports:Controls).
  233.  
  234.                  Ports:Number = Printers:Number
  235.                  Get(Ports,Ports:Number)
  236.                  If Error() then
  237.                     Clear(Ports)
  238.                     PortAdd# = 1
  239.                  .
  240.  
  241.                  Loop
  242.                    Display
  243.                    Accept
  244.                    Case Field()
  245.                    Of ?Printers:Name
  246.                    Of ?Ports:Controls
  247.                       ListControls
  248.                    Of ?Ports:Ok
  249.                       Case ActionMode1
  250.                       Of Action:Insert
  251.                          HighestPrinter  = HighestPrinter + 1
  252.                          Printers:Number = HighestPrinter
  253.                          Add(Printers)
  254.                          Ports:Number    = Printers:Number
  255.                          Add(Ports)
  256.                       Of Action:Change
  257.                          Put(Printers)
  258.                          If PortAdd# then
  259.                             Ports:Number = Printers:Number
  260.                             Add(Ports)
  261.                          Else
  262.                             Put(Ports)
  263.                          .
  264.                       Of Action:Delete
  265.                          Delete(Printers)
  266.                          Delete(Ports)
  267.                       .
  268.                       ChangedFlag = 1
  269.                       Break
  270.                    Of ?Ports:Cancel
  271.                       Break
  272.                  . .
  273.                  Close(Printers_Edit)
  274.                  Return
  275.  
  276. OMIT('╝')
  277. ╔════════════════════════════════════════════════════════════════════════════╗
  278. ║ ListControls - List the Printer Controls and Sequences                     ║
  279. ╚════════════════════════════════════════════════════════════════════════════╝
  280. ListControls       Procedure
  281.  
  282. Controls_List    SCREEN(16,59),SHADOW,CUA,COLOR(1)
  283.                    !dimensions=25,80,25,80
  284.                    !style=D:\CLARION\DEVELOP\DOSLIB\CLARION.STY
  285.                    ROW(1,1)    STRING('█{17}'),COLOR(3)
  286.                      COL(18)   STRING('Printer Control Sequences'),COLOR(31)
  287.                      COL(43)   STRING('█{17}'),COLOR(3)
  288.                    ROW(16,1)   STRING('█▄{57}█'),COLOR(3)
  289.                                REPEAT(14)
  290.                    ROW(2,1)      STRING('█'),COLOR(3)
  291.                    ROW(2,59)     STRING('█'),COLOR(3)
  292.                                .
  293. Printer_Name       ROW(3,4)    STRING(@s53),COLOR(8)
  294.                    ROW(5,4)    LIST(8,53),FROM(Ctl:DisplayGroup),VSCROLL,USE(?Controls),HIDE,COLOR(21,22,68)
  295.                    ROW(14,9)   BUTTON(' &Insert '),SHADOW,KEY(InsKey),USE(?Controls:Insert),COLOR(17,18,39,19,20)
  296.                      COL(20)   BUTTON(' &Change '),SHADOW,KEY(EnterKey),USE(?Controls:Change),COLOR(17,18,39,19,20)
  297.                      COL(31)   BUTTON(' &Delete '),SHADOW,KEY(DelKey),USE(?Controls:Delete),COLOR(17,18,39,19,20)
  298.                      COL(42)   BUTTON('  &Exit  '),SHADOW,KEY(EscKey),USE(?Controls:Exit),COLOR(17,18,39,19,20)
  299.                  .
  300.                  Code
  301.                  Do BuildCtlSequence
  302.                  Open(Controls_List)
  303.                  Printer_Name = Center(Clip(Printers:Name),Size(Printer_Name))
  304.                  Loop
  305.                    Display
  306.                    Accept
  307.                    Selected# = Choice()
  308.                    Get(ControlSequence,Selected#)
  309.  
  310.                    Case Field()
  311.                    Of ?Controls
  312.                       Get(ControlSequence,Selected#)
  313.                    Of ?Controls:Insert
  314.                       ActionMode2 = Action:Insert
  315.                       EditControls
  316.                       Do BuildCtlSequence
  317.                       Display(?Controls)
  318.                       Select(?Controls,Selected#)
  319.                    Of ?Controls:Change
  320.                       ActionMode2 = Action:Change
  321.                       EditControls
  322.                       Do BuildCtlSequence
  323.                       Display(?Controls)
  324.                       Select(?Controls,Selected#)
  325.                    Of ?Controls:Delete
  326.                       ActionMode2 = Action:Delete
  327.                       EditControls
  328.                       Do BuildCtlSequence
  329.                       Display(?Controls)
  330.                       Select(?Controls,Selected#)
  331.                    Of ?Controls:Exit
  332.                       Break
  333.                  . .
  334.                  Close(Controls_List)
  335.                  Return
  336.  
  337. BuildCtlSequence Routine
  338.  
  339.                  Free(ControlSequence)
  340.                  Clear(ControlSequence)
  341.                  Loop Ptr# = 1 to Records(Controls)
  342.                    Get(Controls,Ptr#)
  343.  
  344.                    Clear(Seq:Key)
  345.                    Seq:Printer = Printers:Number
  346.                    Seq:Number  = Controls:Number
  347.                    Get(Sequences,Seq:Key)
  348.                    If Error() then Clear(Sequences).
  349.  
  350.                    Ctl:Number   = Controls:Number
  351.                    Ctl:Name     = Controls:Name
  352.                    Ctl:Sequence = Seq:Sequence
  353.                    Add(ControlSequence)
  354.                  .
  355.                  Exit
  356. OMIT('╝')
  357. ╔════════════════════════════════════════════════════════════════════════════╗
  358. ║ EditControls - Allows Editing of the Control Sequences                     ║
  359. ╚════════════════════════════════════════════════════════════════════════════╝
  360. EditControls       Procedure
  361. ControlAdd         Byte(0)
  362.  
  363. Controls_Edit    SCREEN(8,55),SHADOW,CUA,COLOR(1)
  364.                    !dimensions=25,80,25,80
  365.                    !style=D:\CLARION\DEVELOP\DOSLIB\CLARION.STY
  366.                    ROW(1,1)    STRING('█{10}'),COLOR(3)
  367.                      COL(11)   STRING('Add/Update Printer Control Sequence'),COLOR(31)
  368.                      COL(46)   STRING('█{10}'),COLOR(3)
  369.                    ROW(8,1)    STRING('█▄{53}█'),COLOR(3)
  370.                                REPEAT(6)
  371.                    ROW(2,1)      STRING('█'),COLOR(3)
  372.                    ROW(2,55)     STRING('█'),COLOR(3)
  373.                                .
  374.                    ROW(3,4)    PROMPT('Name   :'),COLOR(4,5,40,6,7)
  375.                      COL(12)   ENTRY(@s40),USE(Controls:Name),COLOR(8,9,38)
  376.                    ROW(4,4)    PROMPT('Con&trol:'),COLOR(4,5,40,6,7)
  377.                      COL(12)   ENTRY(@s40),USE(Seq:Sequence),COLOR(8,9,38)
  378.                    ROW(6,15)   BUTTON('  &Ok  '),SHADOW,KEY(EnterKey),USE(?Sequence:Ok),COLOR(17,18,39,19,20)
  379.                      COL(33)   BUTTON(' &Cancel '),SHADOW,KEY(EscKey),USE(?Sequence:Cancel),COLOR(17,18,39,19,20)
  380.                  .
  381.                  Code
  382.                  ControlAdd = False
  383.  
  384.                  If ActionMode2 <> Action:Insert then
  385.                     Controls:Number = Ctl:Number
  386.                     Get(Controls,Controls:Number)
  387.                     If Error() then Clear(Controls); Beep.
  388.  
  389.                     Clear(Sequences)
  390.                     Seq:Printer  = Printers:Number
  391.                     Seq:Number   = Controls:Number
  392.                     Get(Sequences,Seq:Key)
  393.                     If Error() then
  394.                        Clear(Sequences)
  395.                        ControlAdd = True
  396.                  .  .
  397.  
  398.                  Open(Controls_Edit)
  399.                  Enable(1,Fields())
  400.                  Case ActionMode2
  401.                    Of Action:Insert ;
  402.                    Of Action:Change ; Disable(?Controls:Name)
  403.                    Of Action:Delete ; Disable(?Controls:Name,?Seq:Sequence)
  404.                  .
  405.  
  406.                  Loop
  407.                    Display
  408.                    Accept
  409.                    Case Field()
  410.                    Of ?Sequence:Ok
  411.                       Case ActionMode2
  412.                       Of Action:Insert
  413.                          HighestControl  = HighestControl + 1
  414.                          Controls:Number = HighestControl
  415.                          Add(Controls)
  416.  
  417.                          Seq:Printer     = Printers:Number
  418.                          Seq:Number      = Controls:Number
  419.                          Add(Sequences)
  420.                       Of Action:Change
  421.                          If ~ControlAdd then
  422.                             Put(Sequences)
  423.                          Else
  424.                             Seq:Printer  = Printers:Number
  425.                             Seq:Number   = Controls:Number
  426.                             Add(Sequences,Seq:Key)
  427.                          .
  428.  
  429.                       Of Action:Delete
  430.                          Delete(Sequences)
  431.                       .
  432.                       ChangedFlag = 1
  433.                       Break
  434.                    Of ?Sequence:Cancel
  435.                       Break
  436.                  . .
  437.                  Close(Controls_Edit)
  438.                  Return
  439.  
  440. OMIT('╝')
  441. ╔════════════════════════════════════════════════════════════════════════════╗
  442. ║ LoadControls - Loads the Controls File into Memory                         ║
  443. ╚════════════════════════════════════════════════════════════════════════════╝
  444. LoadControls       Procedure(Que:Printers,Que:Ports,Que:Controls,Que:Sequences)
  445. CurrentFlag        Byte
  446. OverGroup1         Group
  447. Group:Number         Short
  448. Group:Name           String(80)
  449.                    .
  450. OverGroup2         Group
  451. Group:Number1        Short
  452. Group:Number2        Short
  453. Group:Name1          String(80)
  454.                    .
  455.  
  456. LoadingScreen    SCREEN(4,32),CENTER,SHADOW,CUA,COLOR(1)
  457.                    !dimensions=25,80,25,80
  458.                    !style=D:\CLARION\DEVELOP\DOSLIB\CLARION.STY
  459.                    ROW(3,5)    PAINT(1,25),COLOR(8)
  460.                    ROW(1,1)    STRING('█{8}'),COLOR(3)
  461.                      COL(9)    STRING('Loading Printers'),COLOR(2)
  462.                      COL(25)   STRING('█{8}'),COLOR(3)
  463.                    ROW(4,1)    STRING('█▄{30}█'),COLOR(3)
  464.                                REPEAT(2)
  465.                    ROW(2,1)      STRING('█'),COLOR(3)
  466.                    ROW(2,32)     STRING('█'),COLOR(3)
  467.                                .
  468.                                REPEAT(1,25),INDEX(ShowIndx#)
  469. ShowPercentage     ROW(3,4)      STRING(@s1),COLOR(8)
  470.                                .
  471.                  .
  472.  
  473.                    Code
  474.                    Open(LoadingScreen)
  475.                    Free(Que:Printers)  ; Clear(Que:Printers)
  476.                    Free(Que:Controls)  ; Clear(Que:Controls)
  477.                    Free(Que:Ports)     ; Clear(Que:Ports)
  478.                    Free(Que:Sequences) ; Clear(Que:Sequences)
  479.  
  480.                    Open(PrintersFile)
  481.                    If Error() then
  482.                       Close(LoadingScreen)
  483.                    .
  484.  
  485.                    TotalBytes#     = Bytes(PrintersFile)
  486.                    TotalCntr#      = 0
  487.                    TotalRead#      = 0
  488.                    LastCntr#       = 1
  489.  
  490.                    Set(PrintersFile,1)
  491.                    Loop
  492.                      Next(PrintersFile)
  493.                      If Error() then Break.
  494.  
  495.                      TotalRead#   += Bytes(PrintersFile)
  496.                      TotalCntr#    = ((TotalRead# * 100) / TotalBytes#) / 4
  497.                      If TotalCntr# > LastCntr# then
  498.                         Loop ShowIndx# = LastCntr# to TotalCntr#
  499.                           ShowPercentage = '▒'
  500.                         .
  501.                         LastCntr# = TotalCntr#
  502.                      .
  503.                      If Clip(PrinterRecord) = '' then Cycle.
  504.  
  505.                      Case Sub(Clip(Left(Upper(PrinterRecord))),1,9)
  506.                      Of 'PRINTERS '
  507.                         CurrentFlag = 1
  508.                      Of 'PORTS    '
  509.                         CurrentFlag = 2
  510.                      Of 'CONTROLS '
  511.                         CurrentFlag = 3
  512.                      Of 'SEQUENCES'
  513.                         CurrentFlag = 4
  514.                      Else
  515.                         Case CurrentFlag
  516.                         Of 1
  517.                            Group:Number    = Sub(PrinterRecord,1,Instring(' ',PrinterRecord,1)-1)
  518.                            Group:Name      = Sub(PrinterRecord,Instring(' ',PrinterRecord,1)+1,80)
  519.                            Que:Printers    = OverGroup1
  520.                            Add(Que:Printers)
  521.                         Of 2
  522.                            Group:Number    = Sub(PrinterRecord,1,Instring(' ',PrinterRecord,1)-1)
  523.                            Group:Name      = Sub(PrinterRecord,Instring(' ',PrinterRecord,1)+1,80)
  524.                            Que:Ports       = OverGroup1
  525.                            Add(Que:Ports)
  526.                         Of 3
  527.                            Group:Number    = Sub(PrinterRecord,1,Instring(' ',PrinterRecord,1)-1)
  528.                            Group:Name      = Sub(PrinterRecord,Instring(' ',PrinterRecord,1)+1,80)
  529.                            Que:Controls    = OverGroup1
  530.                            Add(Que:Controls)
  531.                         Of 4
  532.                            FirstPtr#       = Instring(' ',PrinterRecord,1)
  533.                            SecondPtr#      = Instring(' ',PrinterRecord,1,FirstPtr#+1)
  534.  
  535.                            Group:Number1   = Sub(PrinterRecord,1,FirstPtr#-1)
  536.                            Group:Number2   = Sub(PrinterRecord,FirstPtr#+1,SecondPtr#-(FirstPtr#+1))
  537.                            Group:Name1     = Sub(PrinterRecord,SecondPtr#+1,80)
  538.                            Que:Sequences   = OverGroup2
  539.                            Add(Que:Sequences)
  540.                    .  . .
  541.                    Close(PrintersFile)
  542.                    Close(LoadingScreen)
  543.                    Return
  544.  
  545. OMIT('╝')
  546. ╔════════════════════════════════════════════════════════════════════════════╗
  547. ║ SaveControls - Saves the Controls File from Memory                         ║
  548. ╚════════════════════════════════════════════════════════════════════════════╝
  549. SaveControls       Procedure
  550.  
  551.                    Code
  552.                    Create(PrintersFile)
  553.                    If Error() then Stop('Error Creating Control File'); Return.
  554.                    Open(PrintersFile)
  555.                    If Error() then Stop('Error Openning Control File'); Return.
  556. !
  557. !                  ----------------------------------------------------------
  558. !                  Add the Printer Names to the Printers File
  559. !                  ----------------------------------------------------------
  560. !
  561.                    PrinterRecord = 'PRINTERS'
  562.                    Add(PrintersFile)
  563.                    Loop Ptr# = 1 to Records(Printers)
  564.                      Get(Printers,Ptr#)
  565.                      PrinterRecord = Clip(Left(Format(Printers:Number,@n_3)))&' '&Printers:Name
  566.                      Add(PrintersFile)
  567.                    .
  568. !
  569. !                  ----------------------------------------------------------
  570. !                  Add the Printer Ports to the Printers File
  571. !                  ----------------------------------------------------------
  572. !
  573.                    PrinterRecord = 'PORTS'
  574.                    Add(PrintersFile)
  575.                    Loop Ptr# = 1 to Records(Ports)
  576.                      Get(Ports,Ptr#)
  577.                      PrinterRecord = Clip(Left(Format(Ports:Number,@n_3)))&' '&Ports:Name
  578.                      Add(PrintersFile)
  579.                    .
  580. !
  581. !                  ----------------------------------------------------------
  582. !                  Add the Printer Control Names to the Printers File
  583. !                  ----------------------------------------------------------
  584. !
  585.                    PrinterRecord = 'CONTROLS'
  586.                    Add(PrintersFile)
  587.                    Loop Ptr# = 1 to Records(Controls)
  588.                      Get(Controls,Ptr#)
  589.                      PrinterRecord = Clip(Left(Format(Controls:Number,@n_3)))&' '&Controls:Name
  590.                      Add(PrintersFile)
  591.                    .
  592. !
  593. !                  ----------------------------------------------------------
  594. !                  Add the Printer Control Sequences to the Printers File
  595. !                  ----------------------------------------------------------
  596. !
  597.                    PrinterRecord = 'SEQUENCES'
  598.                    Add(PrintersFile)
  599.                    Loop Ptr# = 1 to Records(Sequences)
  600.                      Get(Sequences,Ptr#)
  601.                      PrinterRecord = Clip(Left(Format(Seq:Printer,@n_3)))&' '&Clip(Left(Format(Seq:Number,@n_3)))&' '&Seq:Sequence
  602.                      Add(PrintersFile)
  603.                    .
  604.                    Close(PrintersFile)
  605.                    Return
  606.  
  607. OMIT('╝')
  608. ╔════════════════════════════════════════════════════════════════════════════╗
  609. ║ ImportPrinters - Imports Printers from Another Data File                   ║
  610. ╚════════════════════════════════════════════════════════════════════════════╝
  611. ImportPrinters     Procedure
  612.  
  613. ImportFileName     String(64)          ! Filename for Printers File
  614. Imp:Printers       Queue               ! Queue of Printer Names
  615. Imp:Printers:Number  Short             !   Printer Number
  616. Imp:Printers:Grp     Group             !   Display Group
  617. Imp:Printers:Name      String(50)      !   Name of the Printer
  618. Imp:Tagged             String(1)       !   Tagged?
  619.                    . .                 !
  620. Imp:Ports          Queue               ! Queue of Port Names
  621. Imp:Ports:Number     Short             !   Printer Number (Related)
  622. Imp:Ports:Name       String(4)         !   Port Name
  623.                    .                   !
  624. Imp:Controls       Queue               ! Queue of Control Name
  625. Imp:Controls:Number  Short             !   Control Number
  626. Imp:Controls:Name    String(80)        !   Control Name
  627.                    .                   !
  628. Imp:Sequences      Queue               ! Queue of Control Sequences
  629. Imp:Seq:Key          Group             !   Key into this Record
  630. Imp:Seq:Printer        Short           !     Printer Number
  631. Imp:Seq:Number         Short           !     Control Number
  632.                      .                 !   End of Key
  633. Imp:Seq:Sequence     String(80)        !   Control Sequence
  634.                    .                   !
  635.  
  636. Printers_List    SCREEN(23,63),SHADOW,CUA,COLOR(1)
  637.                    !dimensions=25,80,25,80
  638.                    !style=D:\CLARION\CLA_30\CLARION.STY
  639.                    ROW(21,3)   PAINT(1,1),COLOR(23)
  640.                    ROW(1,1)    STRING('█{24}'),COLOR(3)
  641.                      COL(25)   STRING('Import Printers'),COLOR(2)
  642.                      COL(40)   STRING('█{24}'),COLOR(3)
  643.                    ROW(23,1)   STRING('█▄{61}█'),COLOR(3)
  644.                                REPEAT(21)
  645.                    ROW(2,1)      STRING('█'),COLOR(3)
  646.                    ROW(2,63)     STRING('█'),COLOR(3)
  647.                                .
  648. File_Name          ROW(3,6)    STRING(@s53),COLOR(8)
  649.                    ROW(5,6)    LIST(15,53),FROM(Imp:Printers:Grp),HVSCROLL,USE(?Imp:Printers:Name),HIDE,COLOR(21,22,120)
  650.                    ROW(21,4)   BUTTON(' &Mark '),SHADOW,KEY(EnterKey),USE(?Mark),COLOR(17,18,39,19,20)
  651.                      COL(12)   BUTTON(' &Select All '),SHADOW,USE(?Select_All),COLOR(17,18,39,19,20)
  652.                      COL(26)   BUTTON(' &De-Select All '),SHADOW,USE(?DeSelect_All),COLOR(17,18,39,19,20)
  653.                      COL(43)   BUTTON(' &Import '),SHADOW,KEY(EnterKey),USE(?Ok),COLOR(17,18,39,19,20)
  654.                      COL(53)   BUTTON(' &Cancel '),SHADOW,KEY(Esckey),USE(?ImportExit),COLOR(17,18,39,19,20)
  655.                  .
  656.                  Code
  657.                  ImportFileName   = PrinterFileName
  658.                  PrinterFileName = GetFileDetails('','Import Control File','*.CTL')
  659.                  If Clip(PrinterFileName) = '' Then
  660.                     PrinterFileName = ImportFileName
  661.                     Return
  662.                  .
  663.                  Open(Printers_List)
  664.                  File_Name = Center(Clip(PrinterFileName),Size(File_Name))
  665.                  LoadControls(Imp:Printers,Imp:Ports,Imp:Controls,Imp:Sequences)
  666.                  PrinterFileName = ImportFileName
  667.  
  668.                  Loop
  669.                    Accept
  670.                    Get(Imp:Printers,Choice())
  671.                    If Keycode() = MouseLeft2 then Press(EnterKey); Select(?Mark).
  672.  
  673.                    Case Field()
  674.                    Of ?Imp:Printers:Name
  675.                    Of ?Mark
  676.                       If Imp:Tagged = '√' then
  677.                          Imp:Tagged = ' '
  678.                       Else
  679.                          Imp:Tagged = '√'
  680.                       .
  681.                       Put(Imp:Printers)
  682.                       Display(?Imp:Printers:Name)
  683.                       Select(?Imp:Printers:Name,Pointer(Imp:Printers))
  684.                    Of ?Select_All
  685.                       Loop Ptr# = 1 to Records(Imp:Printers)
  686.                         Get(Imp:Printers,Ptr#)
  687.                         Imp:Tagged = '√'
  688.                         Put(Imp:Printers)
  689.                       .
  690.                       Display(?Imp:Printers:Name)
  691.                       Select(?Imp:Printers:Name,Pointer(Imp:Printers))
  692.                    Of ?DeSelect_All
  693.                       Loop Ptr# = 1 to Records(Imp:Printers)
  694.                         Get(Imp:Printers,Ptr#)
  695.                         Imp:Tagged = ' '
  696.                         Put(Imp:Printers)
  697.                       .
  698.                       Display(?Imp:Printers:Name)
  699.                       Select(?Imp:Printers:Name,Pointer(Imp:Printers))
  700.                    Of ?Ok
  701.                       Do ImportNow
  702.                       Break
  703.                    Of ?ImportExit
  704.                       Break
  705.                  . .
  706.                  Close(Printers_List)
  707.                  Return
  708.  
  709. ImportNow        Routine
  710. !
  711. !                --------------------------------------------------------------
  712. !                Import the Control Sequence Numbers First
  713. !                --------------------------------------------------------------
  714. !
  715.                  Sort(Controls,Controls:Name)
  716.                  Loop Ptr# = 1 to Records(Imp:Controls)
  717.                    Get(Imp:Controls,Ptr#)
  718.                    Controls:Name = Imp:Controls:Name
  719.                    Get(Controls,Controls:Name)
  720.                    If Error() then
  721.                       HighestControl  += 1
  722.                       Controls:Number = HighestControl
  723.                       Controls:Name   = Imp:Controls:Name
  724.                       Add(Controls)
  725.                  . .
  726.                  Sort(Controls,Controls:Number)
  727. !
  728. !                --------------------------------------------------------------
  729. !                Import the Printer, Port and Sequence Details Next
  730. !                --------------------------------------------------------------
  731. !
  732.                  Loop Ptr# = 1 to Records(Imp:Printers)
  733.                    Get(Imp:Printers,Ptr#)
  734.                    If Imp:Tagged = '√' then
  735.                       Imp:Tagged = ' '
  736.                       Put(Imp:Printers)
  737.                       Select(?Imp:Printers:Name,Ptr#)
  738.                       Display(?Imp:Printers:Name)
  739.  
  740.                       ChangedFlag     = 1
  741.                       HighestPrinter += 1
  742.                       Clear(Printers)
  743.                       Printers:Name   = Imp:Printers:Name
  744.                       Printers:Number = HighestPrinter
  745.                       Add(Printers)
  746.                       If Error() then Stop('Error Adding Printers Table').
  747.  
  748.                       Imp:Ports:Number = Imp:Printers:Number
  749.                       Get(Imp:Ports,Imp:Ports:Number)
  750.                       If ~Error() then
  751.                          Ports:Number     = Printers:Number
  752.                          Ports:Name       = Imp:Ports:Name
  753.                          Add(Ports)
  754.                          If Error() then Stop('Error Adding Ports Table').
  755.                       .
  756.  
  757.                       Imp:Seq:Printer  = Imp:Printers:Number
  758.                       Get(Imp:Sequences,Imp:Seq:Printer)
  759.                       SeqPtr# = Pointer(Imp:Sequences)
  760.                       Loop
  761.                         Sequences   = Imp:Sequences
  762.                         Seq:Printer = Printers:Number
  763.  
  764.                         Imp:Controls:Number = Imp:Seq:Number
  765.                         Get(Imp:Controls,Imp:Controls:Number)
  766.                         Found# = 0
  767.                         Loop CtlPtr# = 1 to Records(Controls)
  768.                           Get(Controls,CtlPtr#)
  769.                           If Clip(Left(Upper(Controls:Name))) = Clip(Left(Upper(Imp:Controls:Name))) then
  770.                              Seq:Number = Controls:Number
  771.                              Found#     = 1
  772.                         . .
  773.                         If ~Found#  = 1 then
  774.                            Controls = Imp:Controls
  775.                            HighestControl += 1
  776.                            Controls:Number = HighestControl
  777.                            Add(Controls)
  778.                            Seq:Number = Controls:Number
  779.                         .
  780.                         Add(Sequences)
  781.  
  782.                         SeqPtr# += 1
  783.                         Get(Imp:Sequences,Seq:Ptr#)
  784.                         If Error() or Imp:Seq:Printer <> Imp:Printers:Number then Break.
  785.                  . . .
  786.                  Free(Imp:Printers)
  787.                  Free(Imp:Controls)
  788.                  Free(Imp:Ports)
  789.                  Free(Imp:Sequences)
  790.                  Exit
  791.